import 'dart:convert';

StudentActivityResult studentActivityResultFromJson(String str) =>
    StudentActivityResult.fromJson(json.decode(str));

String studentActivityResultToJson(StudentActivityResult data) =>
    json.encode(data.toJson());

class StudentActivityResult {
  StudentActivityResult({
    this.limit,
    this.count,
    this.page,
    this.list,
  });

  int? limit;
  int? count;
  int? page;
  List<StudentActivityReport>? list;

  factory StudentActivityResult.fromJson(Map<String, dynamic> json) =>
      StudentActivityResult(
        limit: json["limit"],
        count: json["count"],
        page: json["page"],
        list: json["list"] != null
            ? List<StudentActivityReport>.from(
                json["list"].map((x) => StudentActivityReport.fromJson(x)))
            : null,
      );

  Map<String, dynamic> toJson() => {
        "limit": limit,
        "count": count,
        "page": page,
        "list": list != null
            ? List<dynamic>.from(list!.map((x) => x.toJson()))
            : null,
      };
}

// class StudentActivityReport {
//   StudentActivityReport({
//     this.assignmentId,
//     this.assignmentName,
//     this.bookId,
//     this.bookLevel,
//     this.bookTitle,
//     this.entry,
//     this.points,
//     this.session,
//     this.type,
//     this.when,
//   });

//   String? assignmentId;
//   String? assignmentName;
//   String? bookId;
//   String? bookLevel;
//   String? bookTitle;
//   String? entry;
//   int? points;
//   String? session;
//   String? type;
//   int? when;

//   factory StudentActivityReport.fromJson(Map<String, dynamic> json) =>
//       StudentActivityReport(
//         assignmentId: json["assignmentId"],
//         assignmentName: json["assignmentName"],
//         bookId: json["bookId"],
//         bookLevel: json["bookLevel"],
//         bookTitle: json["bookTitle"],
//         entry: json["entry"],
//         points: json["points"],
//         session: json["session"],
//         type: json["type"],
//         when: json["when"],
//       );

//   Map<String, dynamic> toJson() => {
//         "assignmentId": assignmentId,
//         "assignmentName": assignmentName,
//         "bookId": bookId,
//         "bookLevel": bookLevel,
//         "bookTitle": bookTitle,
//         "entry": entry,
//         "points": points,
//         "session": session,
//         "type": type,
//         "when": when,
//       };
// }

class StudentActivityReport {
    StudentActivityReport({
        this.type,
        this.when,
        this.points,
        this.assignmentName,
        this.assignmentId,
        this.entry,
        this.session,
        this.bookId,
        this.bookTitle,
        this.bookLevel,
        this.score,
        this.percentage,
        this.submittedAnswers,
        this.questions,
        this.gradedAnswers,
        this.answerKey,
        this.tradAnswerKey,
        this.simple,
    });

    String? type;
    int? when;
    int? points;
    String? assignmentName;
    String? assignmentId;
    String? entry;
    String? session;
    String? bookId;
    String? bookTitle;
    String? bookLevel;
    int? score;
    int? percentage;
    Map<String, List<String>>? submittedAnswers;
    int? questions;
    Map<String, bool>? gradedAnswers;
    Map<String, List<String>>? answerKey;
    Map<String, List<String>>? tradAnswerKey;
    bool? simple;

    factory StudentActivityReport.fromJson(Map<String, dynamic> json) => StudentActivityReport(
        type: json["type"],
        when: json["when"],
        points: json["points"],
        assignmentName: json["assignmentName"],
        assignmentId: json["assignmentId"],
        entry: json["entry"] == null ? null : json["entry"],
        session: json["session"] == null ? null : json["session"],
        bookId: json["bookId"] == null ? null : json["bookId"],
        bookTitle: json["bookTitle"] == null ? null : json["bookTitle"],
        bookLevel: json["bookLevel"] == null ? null : json["bookLevel"],
        score: json["score"] == null ? null : json["score"],
        percentage: json["percentage"] == null ? null : json["percentage"],
        submittedAnswers: json["submittedAnswers"] == null ? null : Map.from(json["submittedAnswers"]).map((k, v) => MapEntry<String, List<String>>(k, List<String>.from(v.map((x) => x)))),
        questions: json["questions"] == null ? null : json["questions"],
        gradedAnswers: json["gradedAnswers"] == null ? null : Map.from(json["gradedAnswers"]).map((k, v) => MapEntry<String, bool>(k, v)),
        answerKey: json["answerKey"] == null ? null : Map.from(json["answerKey"]).map((k, v) => MapEntry<String, List<String>>(k, List<String>.from(v.map((x) => x)))),
        tradAnswerKey: json["tradAnswerKey"] == null ? null : Map.from(json["tradAnswerKey"]).map((k, v) => MapEntry<String, List<String>>(k, List<String>.from(v.map((x) => x)))),
        simple: json["simple"] == null ? null : json["simple"],
    );

    Map<String, dynamic> toJson() => {
        "type": type,
        "when": when,
        "points": points,
        "assignmentName": assignmentName,
        "assignmentId": assignmentId,
        "entry":  entry,
        "session":  session,
        "bookId":  bookId,
        "bookTitle":  bookTitle,
        "bookLevel":  bookLevel,
        "score":  score,
        "percentage":  percentage,
        "submittedAnswers":  submittedAnswers,
        "questions":  questions,
        "gradedAnswers":  gradedAnswers,
        "answerKey":  answerKey,
        "tradAnswerKey": tradAnswerKey,
        "simple": simple,
    };
}
